﻿ 

	
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="客户合同">  
    <meta name="description" content="客户合同">  
    <title>客户合同管理</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>

</head>  
<body>  
    
      
    <table id="dg" title="客户合同管理" style="height:550px"  
            url="/customer/customerContract/list.do"  
            toolbar="#toolbar" pagination="true"  
            rownumbers="true" pageSize="20" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  

    </table>  
    <div id="toolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">新增</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit()">修改</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deletes()">删除</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="find()">查询</a>
    </div>  
   
    <div id="dlg" style="display:none;">  
    	   <!--
            <iframe "  src="/customer/customerContract/info.do?url=/customer/customerContract/save.do" style="width:99%;height:99%"></iframe>
         -->   
    </div> 
     <div id="dlg_edit" style="display:none;">  
     	    <!--
            <div id="tab_panel" class="easyui-tabs" style="width:1200px;height:450px">  
                         <div title="基本信息" url="/customer/customerContract/info.do?url=/customer/customerContract/update.do"  style="padding:10px">  
                             <iframe   src="" style="width:90%;height:80%"></iframe>  
                         </div>
                         <div title="合同人员" url="/customer/customerContractStaff/orgManager.do"  style="padding:10px">  
                             <iframe   src="" style="width:90%;height:80%"></iframe>  
                         </div>
                         <div title="合同附件" url="/customer/customerContractAttachment/managerPage.do"  style="padding:10px">  
                             <iframe   src="" style="width:90%;height:80%"></iframe>  
                         </div>
                         <div title="关联公司" url="/customer/customerContractServiceCompany/managerPage.do"  style="padding:10px">  
                             <iframe   src="" style="width:90%;height:80%"></iframe>  
                         </div>
                         
            </div>          
            -->   
            
    </div>
    <!-- query form窗体(开始) -->  
     <div id="dlg_query" style="display:none;">  
    	  <!-- 
        
        <form id="fm_query" method="post" novalidate>  
            
              
	        		     <div class="fitem">  
                     <label style="width:100px">合同编号:</label>                                            
                     <input name="nbr" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">客户:</label>                       
                     <input name="custName" class="easyui-box">                       
                   </div>	        		     
	        		     
        	  	   	 <div class="fitem">  
                     <label style="width:100px">合同格式:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="contractStyle" style="width:150px;"  data-options="data:__getConstantCategory('ContractStyle'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
        	  	   	 <div class="fitem">  
                     <label style="width:100px">合同类型:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="contractType" style="width:150px	;"  data-options="data:__getConstantCategory('ContractType'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      		        		             		     
              
              
        </form>  
        <div  style="text-align:center">  
          <a href="javascript:void(0)" id="btn-query" class="easyui-linkbutton" iconCls="icon-ok" ">查询</a>  
          <a href="javascript:void(0)" id="btn-query-close" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>  
        </div>  
        -->
    </div> 
    <!-- query form窗体(结束) -->  
   
    <script type="text/javascript">  
        var url; 
        var contractId; 
        var addWin;
        var editWin;
        
         var optWin = $.window({
		       		 title:"新增合同",
		       		 tplRef:"dlg",//这个属性指定模板id
		       		 height:580,	
		       		 width:950,	       		 
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  
		       		 	  var iframe= this.find("iframe");
		       		 	  
		       		 	   iframe.load(function(){
		       		 	  	  
		       		 	  	    iframe.contents().find("#btn-close").click(function(){		       		 	  	
		       		 	  	      curWin.window('close');
		       		 	        });
		       		 	  	    iframe[0].contentWindow.closeWin=function(){
					                      	curWin.window('close');
					                      	  
				                };
				                iframe[0].contentWindow.refresh=function(){
					           	   if(curWin.openerWin.refresh) curWin.openerWin.refresh();
				                };
		       		 	  	   
		       		 	  	  
		       		 	  });
		       		 	  
		       		 	 
		       		   
		       		 }
		    });
        
         var queryWin = $.window({
		       		 title:"职位查询",
		       		 tplRef:"dlg_query",//这个属性指定模板id
		       		 height:200,		       		 
		       		 width:450,
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  var doForm=curWin.find('#fm_query');
		       		 	  curWin.doForm=doForm;
		       		 	  this.find("#btn-query-close").click(function(){		       		 	  	
		       		 	  	   curWin.window('close');
		       		 	  });
		       		 	  this.find("#btn-query").click(function(){
		       		 	  			                 		  
		                 		 //var formdata=$('#fm_query').formToArray(); 
		                 		 curWin.window('close');
		                 		 var formdata=curWin.find('#fm_query').formToArray();   		 
		                 		 curWin.openWin.query(formdata);
		              });
		       		   
		       		 }
		    });
        
        function add(){         	 
            
            optWin.find('iframe')[0].contentWindow.location.href='/customer/customerContract/info.do';
            optWin.window('open'); 
            optWin.openerWin=window;                                               
            optWin.window('setTitle','新增合同');
        }  
        function refresh(){        	 
        	  $('#dg').datagrid('reload');
        }	
        function doEdit(id){  
        	  optWin.find('iframe')[0].contentWindow.location.href='/customer/customerContract/detail.do?type=UPDATE&contractId='+id;    
        	   optWin.window('open');
		         optWin.openerWin=window;    
		         
		         
		         optWin.window('setTitle','修改合同');
        	
        }	
        function edit(){  
            //var row = $('#dg').datagrid('getSelected');  
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){  
                $('#dlg-edit').dialog('open').dialog('setTitle','修改客户合同');  
                //$('#fm').form('load',rows[0]);  
                //$('#fm').form('load','/customer/customerContract/get.do?id='+rows[0].id);  
                //var tab=$('#tab_panel').tabs('getTab', 0);
                //contractId=rows[0].id;
                //tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?url=/customer/customerContract/update.do&contractId="+contractId;
                //url = '/customer/customerContract/update.do';
                doEdit(rows[0].id);
            }  
        }  
        function save(){          	   
        	  if (!$('#fm').form('validate')) return; 
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');                      
                    if (result.success == true){  
                        $.messager.alert('信息',result.msg,'info');  
                        $('#dlg').dialog('close');      // close the dialog  
                        $('#dg').datagrid('reload');    // reload the user data  
                    } else {  
                        $.messager.alert('错误',result.msg,'error');
                    }  
                }  
            });  
        }  
        function deletes(){  
            var row = $('#dg').datagrid('getSelected');  
            
            var rows = $('#dg').datagrid('getSelections');  

            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要删除的行','info');
            	 return;
            }
            if (rows){  
                $.messager.confirm('重要提示','确定要删除?',function(r){  
                    if (r){  
                        $.post('/customer/customerContract/delete.do',{ids:getRecordArray(rows,'id').join(',')},function(result){  
                            if (result.success){  
                                $('#dg').datagrid('reload');    // reload the user data  
                            } else {  
                                 
                                $.messager.alert('错误',result.errorMsg,'error'); 
                            }  
                        },'json');  
                    }  
                });  
            }  
        }  
        function find(){  
              
                queryWin.window('open');   
               queryWin.openWin=window; 
              
        } 
        	
        
         function query(formdata){  
                
                $('#dg').datagrid({
	                  queryParams: array2json(formdata)
                });
              
        }
        
        //生成grid的字段,需要字典的自动转换
        $('#dg').datagrid({
        	   columns:[[
        	   	
        	   	   {field:'nbr',title:'合同编号', width:100}
        	   	   ,{field:'abbrName',title:'客户简称', width:100}
        	   	   ,{field:'custName',title:'客户中文名', width:100,hidden : true}
        	   	   ,{field:'custNameEn',title:'客户英文名', width:100,hidden : true}
        	   	   ,{field:'arRate',title:'费率', width:100}
        	   	   ,{field:'minAr',title:'最低收费', width:100}
        	   	   ,{field:'preArD',title:'预付款期限', width:100,hidden : true}
        	   	   ,{field:'arD',title:'付款期限', width:100}
        	   	   ,{field:'trialMonths',title:'保证期(试用期)', width:100}
        	   	   ,{field:'refundRate',title:'退款比例', width:100}
        	   	    ,{field:'beginD',title:'合同开始日期', width:100,hidden : true}
        	   	   ,{field:'endD',title:'合同结束日期', width:100}
        	   	   ,{field:'manager',title:'客户经理', width:100}
        	   	   ,{field:'deptNames',title:'部门', width:100}
        	   	   ,{field:'contractStyle',title:'合同格式', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('ContractStyle', value);
        	   		      }
        	   	     }
        	   	   ,{field:'contractType',title:'类型', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('ContractType', value);
        	   		      }
        	   	     }
        	   	   ,{field:'lang',title:'语种', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('ContractLang', value);
        	   		      }
        	   	     }
        	   	   ,{field:'preAr',title:'预付款', width:100}
        	   	   ,{field:'preUnit',title:'预付款单位', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('MoneyType', value);
        	   		      },hidden : true
        	   	     }
        	   	   ,{field:'delayRate',title:'滞纳金比例', width:100,hidden : true}
        	   	  ,{field:'creator',title:'录入人', width:100,hidden : true}
        	   	   ,{field:'createDt',title:'录入时间', width:100,hidden : true}
        	   	   ,{field:'modifier',title:'修改人', width:100,hidden : true}
        	   	   ,{field:'modifiedDt',title:'修改时间', width:100,hidden : true}
        	   	                	   	          	   	           	   	
        	   	
        	   ]]
        	   ,onDblClickRow: function(rowIndex, rowData){
        	    	//$('#dlg').dialog('open').dialog('setTitle','修改客户合同');                  
                //$('#fm').form('load','/customer/customerContract/get.do?id='+rowData.id);  
                //url = '/customer/customerContract/update.do';        	    	
                doEdit(rowData.id);
        	    }
        	    ,onClickRow: function(rowIndex, rowData){
        	    	
        	    	var tab = $('#tab_panel').tabs('getSelected');
        	      contractId=rowData.contractId;            	              	      
        	    	tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?contractId="+contractId;
                	    	
        	    }
        }); 
        //完成-生成grid的字段
        /*
         $('#tab_panel').tabs({
        	    onSelect: function(title,index){
        	    
        	    	var tab=$('#tab_panel').tabs('getTab', index);
        	      
        	    	tab.find('iframe')[0].contentWindow.location.href=tab.attr('url')+"?contractId="+contractId;
        	    	
        	    	
        	    }
        });
        */
        
    </script>  
     
     

     
     
     
</body>  
</html>